package com.hspedu.codeblock;

public class CodeBlock01 {
    public static void main(String[] args) {
        Movie movie = new Movie("疯狂的石头");
        Movie movie1 = new Movie("唐人街探", 66.6, "小龙");

    }
}


class Movie{
    private String name;
    private double price;
    private String director;//导演

    {
        System.out.println("电影屏幕打开...");
        System.out.println("广告开始...");
        System.out.println("电影正式开始...");
    }

    //构造器
    //下面的三个构造器都有想用的语句，
    //1.这时可以将相同的语句放入到一个代码块中即可
    //2.当我们调用这个构造器时，都会调用代码块的内容
    //3.代码块的顺序优先于构造器..
    public Movie(String name) {
       /* System.out.println("电影屏幕打开...");
        System.out.println("广告开始...");
        System.out.println("电影正式开始...");*/
        this.name = name;
        System.out.println("Movie(String name)构造器被调用~");

    }
    public Movie(String name, double price) {
    /*    System.out.println("电影屏幕打开...");
        System.out.println("广告开始...");
        System.out.println("电影正式开始...");*/
        this.name = name;
        this.price = price;
        System.out.println("Movie(String name, double price)");
    }

    public Movie(String name, double price, String director) {
/*        System.out.println("电影屏幕打开...");
        System.out.println("广告开始...");
        System.out.println("电影正式开始...");*/
        this.name = name;
        this.price = price;
        this.director = director;
    }
}